# 工作时长
# 2025/02/24

import datetime


def main():
    date_list = []
    # 读取数据 格式化日期
    with open("../../data/2023_a.txt", "r") as file:
        date_str = file.readline()
        while date_str and date_str != '\n':
            date_str, time_str = date_str.split()
            year, month, day = map(int, date_str.split("-"))
            hour, minute, sec = map(int, time_str.split(":"))
            date_list.append(datetime.datetime(year, month, day, hour=hour, minute=minute, second=sec))
            date_str = file.readline()
    date_list.sort()  # 对日期排序
    res = 0
    while date_list:  # 按照顺序由弹出两个末尾日期计算工作时长
        end_time = date_list.pop()
        start_time = date_list.pop()
        res += end_time.timestamp() - start_time.timestamp()
    print(res)


if __name__ == '__main__':
    main()
